<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Blog</title>
    <link rel="stylesheet" href="./CSS/common.css">
    <link rel="stylesheet" href="./CSS/blog_detail.css">
      <!-- 引入 editor.md 的依赖 -->
    <link rel="stylesheet" href="editor.md/css/editormd.min.css" />
    <script src="JS/jquery.min.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>
    <script src="./JS/login.js"></script>
    <script src="./JS/jquery.min.js"></script>
    <script>
    //检验登录状态
        checkLogin();
    </script>
</head>
<body>
     <!--导航栏-->
     <div class="nav">
        <img src="image/logo.jpg" alt="">
        <span class="title">我的博客系统</span>
        <!--留白占位-->
        <span class="spacer"></span>
        <!--这是按钮-->
        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">写博客</a>
        <a href="logout" onclick="alert('注销成功')">注销</a>
        <a href="update.html">设置资料</a>
    </div>

     <!--页面内容-->
     <div class="container">

        <!--左侧个人简介-->
        <div class="container-left">
            <!--用户信息-->
            <div class="card">
                <img src="image/个人简介.jpg" alt="">
                <h3></h3>
            
                <div class="count">
                    
                </div>
                <div class="count">
                    
                </div>
            </div>
        </div>

        <!--右侧内容详情-->
        <div class="container-right">
            <div class="blog-content">
                <h3></h3>
                <div class="date"></div>
                <div id="content" style="opacity: 80%;"></div>
            </div>
        </div>
    </div>
    

    <script>
        function getBlog(){
            $.ajax({
                type:'get',
                url:'blog'+location.search,
                success:function(body){
                    let h3=document.querySelector('.blog-content h3');
                    h3.innerHTML=body.title;
                    let date=document.querySelector('.date');
                    date.innerHTML=body.postTime;
                    // let text=document.querySelector('#text');
                    // text.innerHTML=body.content;
                    //将markdown字符串的渲染结果转为HTML文档
                    editormd.markdownToHTML('content', {
                        markdown: body.content
                    });
                }
            });
        }
        getBlog();
        //获取当前文章作者信息
    function authorInfo(){
        $.ajax({
            type:'get',
            url:'userInfo'+location.search,
            success:function(body){
                let h3=document.querySelector('.card h3');
                h3.innerHTML=body.nickName;
                if(body.isYourBlog){
                    let deleteA=document.createElement('a');
                    deleteA.className='deleteBlog';
                    deleteA.innerHTML='删除文章';
                    deleteA.href='deleteBlog'+location.search;
                    let nav=document.querySelector('.nav');
                    nav.appendChild(deleteA);
                }
            }
        });
    }
    authorInfo();
    </script>
</body>
</html>